package com.biz.primus.app.rest.handler.impl;

import com.biz.primus.app.rest.handler.BuildRequestHandler;
import com.biz.primus.base.exception.BizBusinessException;
import com.biz.primus.base.vo.handler.IPAddressAware;
import com.biz.primus.base.vo.handler.IRequestVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * ip地址处理器,如果请求对象实现了IIPVo接口,将请求者ip写入该对象
 *
 * @author jun.liu
 * @usage
 * @reviewer
 * @since 2017年11月3日
 */
@Component
@Slf4j
public class IpAddressHandler implements BuildRequestHandler
{

    @Override
    public void handle(HttpServletRequest request, IRequestVo requestVo) throws BizBusinessException
    {
        if (requestVo instanceof IPAddressAware)
        {
            IPAddressAware ipvo = (IPAddressAware) requestVo;
//			ipvo.setIp(HttpServletHelper.getClientIP(request));
        }
    }

    @Override
    public int getOrder() {
        return BuildRequestHandler.IpAddressHandlerOrderVaule;
    }

}
